home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
libkb100.zip
/
LIBKB-1.00
/
INCLUDE
/
KB.H
next >
Wrap
C/C++ Source or Header
|
1996-07-23
|
15KB
|
386 lines
/* kb.h -- interface of the 'libkb' keyboard library
version 1.00, 23 Jul 1996.
Copyright (C) 1995, 1996 Markus Franz Xaver Johannes Oberhumer
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Markus F.X.J. Oberhumer
markus.oberhumer@jk.uni-linz.ac.at
*/
#ifndef __LIBKB_KB_H
#define __LIBKB_KB_H
#define KB_LIBKB KB_VERSION_ID
#define KB_VERSION_ID 0x1000 /* version + patchlevel */
#define KB_VERSION_STRING "1.00"
#define KB_VERSION_DATE "23 Jul 1996"
#if defined(MSDOS) || defined(__MSDOS__) || defined(__EMX__)
# define __KB_MSDOS
# if defined(__32BIT__) || defined(__FLAT__) || defined(__GNUC__)
# define __KB_MSDOS32
# else
# define __KB_MSDOS16
# endif
#elif defined(__linux__) && defined(__GNUC__)
# define __KB_LINUX
# define __KB_UNIX
#else
# error unsupported compiler
#endif
#if defined(__KB_MSDOS)
# include <conio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* utility macros for bits accessing */
#define KB_ALL_MASK(x,mask) (((x) & (mask)) == (mask))
#define KB_ANY_MASK(x,mask) (((x) & (mask)) != 0)
#define KB_NO_MASK(x,mask) (((x) & (mask)) == 0)
/***********************************************************************
// keyboard access
************************************************************************/
/* installation of keyboard handler */
int kb_install(unsigned long flags); /* install keyboard handler */
void kb_remove(void); /* remove keyboard handler */
#define kb_flags() ((unsigned long) _kb_flags)
#define kb_mode() ((int) _kb_mode)
/* update the keyboard - needed under Linux */
void kb_update(void);
/* access all keys */
#define kb_key(scan) ((unsigned char) _kb_key[scan])
#define kb_keys_pressed() ((int) _kb_keys_pressed)
#define kb_last_key() ((unsigned short) _kb_last_key)
#define kb_shift() ((unsigned short) _kb_shift)
#define kb_last_key_set(k) ((void) (_kb_last_key = (k)))
#define kb_shift_off(s) ((void) (_kb_shift &= ~(s)))
#define kb_shift_on(s) ((void) (_kb_shift |= (s)))
/* read a single keypress */
unsigned kb_keypress(void); /* basic access function */
unsigned long kb_inkey(void); /* full info keypress */
unsigned kb_getkey(void); /* compatible to getkey() */
int kb_kbhit(void); /* compatible to kbhit() */
/* you are allowed to modify the following variables */
extern volatile unsigned short _kb_shift; /* current shift state */
extern volatile unsigned short _kb_last_key;/* last key pressed */
/* these are READ ONLY - use the access-macros above */
extern volatile unsigned char _kb_key[128]; /* the key flags */
extern volatile int _kb_keys_pressed; /* number of keys pressed */
extern unsigned long _kb_flags; /* flags after kb_install() */
extern int _kb_mode; /* do we have a keyboard handler? */
/***********************************************************************
// flags - kb_install() and kb_flags()
// note: the only flag you probably need is emergency exit
************************************************************************/
/* pass these to kb_install() */
#define KB_FLAG_NO_ATEXIT 0x0001 /* do not use atexit() */
#define KB_FLAG_NO_SIGNAL 0x0002 /* do not install signal handler */
#define KB_FLAG_NO_LOCK 0x0004 /* do not lock memory */
#define KB_FLAG_SIGINT 0x0010 /* raise SIGINT on Control-C */
#define KB_FLAG_EMERGENCY_EXIT 0x0020 /* enable emergency exit */
#define KB_FLAG_EMERGENCY_SIGALRM 0x0040 /* enable SIGALRM emergency */
#define KB_FLAG_LINUX_NO_VT 0x0100 /* no virtual term switching */
#define KB_FLAG_LINUX_VT_NO_KEY 0x0200 /* release all keys after VT */
#define KB_FLAG_DJGPP_NO_RM 0x0400 /* no real-mode handler */
#define KB_FLAG_REPEAT_OFF 0x1000 /* turn off key repeat */
/* these information bits are set by kb_install() but do not cause an error */
#define KB_FLAG_ATEXIT_FAILED 0x00010000L /* error atexit() */
#define KB_FLAG_SIGNAL_FAILED 0x00020000L /* error installing signals */
#define KB_FLAG_LOCK_FAILED 0x00040000L /* error while locking memory */
/* these information bits are set by kb_install() */
#define KB_FLAG_ATEXIT_DONE 0x00100000L /* atexit() was called */
#define KB_FLAG_SIGNAL_DONE 0x00200000L /* signal handler installed */
#define KB_FLAG_LOCK_DONE 0x00400000L /* memory was locked */
/***********************************************************************
// keyboard scan codes - kb_key()
// 1-88,96-111 are fairly standard and should probably not be changed
************************************************************************/
/* get the name of a key */
const char *kb_keyname(int scan);
/* raw keys 1-88, 87 keys */
#define KB_SCAN_ESC 1
#define KB_SCAN_1 2
#define KB_SCAN_2 3
#define KB_SCAN_3 4
#define KB_SCAN_4 5
#define KB_SCAN_5 6
#define KB_SCAN_6 7
#define KB_SCAN_7 8
#define KB_SCAN_8 9
#define KB_SCAN_9 10
#define KB_SCAN_0 11
#define KB_SCAN_MINUS 12
#define KB_SCAN_EQUAL 13
#define KB_SCAN_BACKSPACE 14
#define KB_SCAN_TAB 15
#define KB_SCAN_Q 16
#define KB_SCAN_W 17
#define KB_SCAN_E 18
#define KB_SCAN_R 19
#define KB_SCAN_T 20
#define KB_SCAN_Y 21
#define KB_SCAN_U 22
#define KB_SCAN_I 23
#define KB_SCAN_O 24
#define KB_SCAN_P 25
#define KB_SCAN_OPENBRACE 26
#define KB_SCAN_CLOSEBRACE 27
#define KB_SCAN_ENTER 28
#define KB_SCAN_LCONTROL 29 /* Left Control */
#define KB_SCAN_A 30
#define KB_SCAN_S 31
#define KB_SCAN_D 32
#define KB_SCAN_F 33
#define KB_SCAN_G 34
#define KB_SCAN_H 35
#define KB_SCAN_J 36
#define KB_SCAN_K 37
#define KB_SCAN_L 38
#define KB_SCAN_COLON 39
#define KB_SCAN_QUOTE 40
#define KB_SCAN_BACKQUOTE 41
#define KB_SCAN_LSHIFT 42 /* Left Shift */
#define KB_SCAN_BACKSLASH 43
#define KB_SCAN_Z 44
#define KB_SCAN_X 45
#define KB_SCAN_C 46
#define KB_SCAN_V 47
#define KB_SCAN_B 48
#define KB_SCAN_N 49
#define KB_SCAN_M 50
#define KB_SCAN_COMMA 51
#define KB_SCAN_PERIOD 52
#define KB_SCAN_SLASH 53
#define KB_SCAN_RSHIFT 54 /* Right Shift */
#define KB_SCAN_MULTIPLY_PAD 55
#define KB_SCAN_ALT 56 /* Left Alt */
#define KB_SCAN_LALT KB_SCAN_ALT
#define KB_SCAN_SPACE 57
#define KB_SCAN_CAPSLOCK 58
#define KB_SCAN_F1 59
#define KB_SCAN_F2 60
#define KB_SCAN_F3 61
#define KB_SCAN_F4 62
#define KB_SCAN_F5 63
#define KB_SCAN_F6 64
#define KB_SCAN_F7 65
#define KB_SCAN_F8 66
#define KB_SCAN